package cn.itcast.order.listener;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

//@Component
public class MQListerner {

    /**
     * 模拟通过user服务调用rabbit修改订单信息
     * @param orderId
     */
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "user.queue"),
            exchange = @Exchange(value = "topic.user",type = ExchangeTypes.TOPIC),
            key = "query.userinfo"
    ))
    public void listerner(Map<String,Object> orderId){
        // 修改订单信息-这里可调用orderService操作数据库
        System.out.println("模拟修改订单信息成功！订单ID："+orderId);
    }
}
